package cn.itsource.system.controller;

import cn.itsource.base.util.AjaxResult;
import cn.itsource.system.domain.dto.PhoneUserFormDto;
import cn.itsource.system.service.IVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
public class VerifyController {
    @Autowired
    private IVerifyService verifyService;
    @GetMapping("/getImgVerifyCode/{key}")
    public AjaxResult getImgVerifyCode(@PathVariable("key")String key){
        System.out.println(key);
        //根据key去绑定一个code
        //code要去生成一个图片验证码
        //图片验证码 保存到redis里面去 设置过期时间5分钟
        //最后返回图片 字符串的图片
        return verifyService.getImgVerifyCode(key);
    }

    @PostMapping("/sendMobileCode")
    public AjaxResult sendMobileCode(@RequestBody @Valid PhoneUserFormDto phoneUserFormDto){
        return verifyService.sendMobileCode(phoneUserFormDto);
    }
}
